package com.spzx.product.api.factory;

import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteBrandService;
import com.spzx.product.api.domain.Brand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * projectName: spzx-parent
 *
 * @author: 王宝贵
 * time: 2024/10/9 11:32 周三
 * description:
 */
@Slf4j
public class RemoteBrandServiceFallbackFactory implements FallbackFactory<RemoteBrandService> {


    @Override
    public RemoteBrandService create(Throwable cause) {

        log.error("调用{}服务出现问题 :{}", ServiceNameConstants.PRODUCT_SERVICE,cause.getMessage());
        return new RemoteBrandService() {

            @Override
            public R<List<Brand>> getBrandAllList(String surce) {
                return R.fail("调用查询所有品牌出现问题："+cause.getMessage());
            }
        };
    }
}